#include "bla.h"

int readings[400]; 
int ledPin = 13;                // LED connected to digital pin 13
int buf=0;
int val=0;
int treshold=200;
int index=0;
long time=0;

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);

  for (int i = 0; i < 400; i++)
    readings[i] = 0; 
    
  LEDblink();
}

void loop()            
{
  if(millis()-time) > 3000){
    printErg();
    time=millis(); 
  }
    
  index++;
  val = analogRead(0);
  readings[index]=val;

  if (val - buf > treshold) {
    digitalWrite(ledPin, HIGH);
  }
  if (buf - val > treshold) {
    digitalWrite(ledPin, LOW);
  }
  buf = val;


  if (index >= 400){
    for (int i = 0; i < 400; i++){
      Serial.print(readings[i], DEC);
      Serial.print(',');
      delay(10);
    }
    index=0;
  }
}

